package com.example.framework

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

open class ComponentVM<T>(): ViewModel() {


    open fun handleIntent(intent:T){}


    /**
     * 只能在kt中使用
     * 可读可写
     */
    @JvmSynthetic
    protected fun <K> LiveData<K>.mutate(): MutableLiveData<K> {
        return this as MutableLiveData<K>
    }

    /**
     * 仅可读
     */
    @JvmSynthetic
    protected fun <K> MutableLiveData<K>.immutate(): LiveData<K> {
        return this as LiveData<K>
    }

    open class ComponentIntent{}

    open class ClickIntent : ComponentIntent(){}

    open class ExposeIntent : ComponentIntent(){}

    interface IntentListener{
        fun onIntent(intent:ComponentIntent)
    }
}